import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Userinfo } from '../model/userInfo';
import { CommonApi } from './commonApi';
import { RequestService } from './request.service';

@Injectable({
  providedIn: 'root'
})
export class AdminApiService extends CommonApi<Userinfo>{

  constructor(
    private request: RequestService
  ) {
    super(request, '/admin')
  }

  public updateActivateStatus(activateStatus: number): Observable<any> {
    const url = '/admin/update/activateStatus';
    return this.request.post(url, { activateStatus: activateStatus });
  }

  public aSignRole(userId:number, roleIds: Array<number>): Observable<any> {
    const url = 'admin/role/update';
    let data = new FormData();
    data.append('adminId', userId.toString());
    data.append('roleIds', roleIds.toString());
    return this.request.post(url, data)
  }
}
